package com.igeek.shop.service.admin;

import java.util.List;

import com.igeek.shop.dao.BaseDao;
import com.igeek.shop.entity.Category;

public class AdminCategoryServiceImpl implements AdminCategoryService {
	private BaseDao<Category> dao = new BaseDao<Category>();
	@Override
	public void addCategory(Category category) {
		String sql = "insert into category values(?,?)";
		Object [] params = {category.getCid(),category.getCname()};
		dao.update(sql, params);
		
	}
	@Override
	public List<Category> queryCategory() {
		String sql = "select * from category";
		Object [] params = {};
		Object list = dao.getList(sql, params, new Category());
		List<Category> categoryList = (List<Category>) list;
		return categoryList;
	}
	@Override
	public void updateCategory(Category category) {
		String sql = "update category set cname = ? where cid = ?";
		Object [] params = {category.getCname(),category.getCid()};
		dao.update(sql, params);
	}
	@Override
	public void deleteCategory(Category category) {
		String sql = "delete from category where cid = ?";
		Object [] params = {category.getCid()};
		dao.update(sql, params);
	}

}
